home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9611 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: news.acadia.net!usenet
  2. From: steven2@salesbook.com (Steve Nutt)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: C++ error in borland, is this a compiler bug?
  5. Date: Sun, 03 Mar 1996 06:51:45 GMT
  6. Organization: DET
  7. Message-ID: <4hb6rg$9gm@post.acadia.net>
  8. References: <4h7suv$760@news2.realtime.net>
  9. Reply-To: steven2@salesbook.com
  10. NNTP-Posting-Host: blf7.acadia.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. brian_d@sheshunoff.com wrote:
  14.  
  15. >I am using borland C++4.52, and OWL.  Owl has very little to do with this, though.
  16. >GetModule() returns a TModule *.  TModule has a member function LoadString that returns
  17. >a string object.  string class has a member function c_str() that return a char * to the actual string.
  18.  
  19. >        BOOL newInstl;
  20. >        long pgmDirSpace;
  21.  
  22.  
  23. >I get the following error when trying to compile the following (modified for example)
  24. >"Destructor for string required in conditional expression in function ..."
  25.  
  26.  
  27. >    pgmDirSpace=newInstl ? atol((GetModule()->LoadString(ROOM_NEW)).c_str())
  28. >                           : atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  29.  
  30.  
  31. >But if I change it to this, it works fine.
  32. >    if(newInstl) pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
  33. >    else pgmDirSpace=atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  34.  
  35. >This will also compile fine.  Thrown in for example only.
  36. >    switch(newInstl)
  37. >    {
  38. >    case TRUE;
  39. >    pgmDirSpace=atol((GetModule()->LoadString(ROOM_NEW)).c_str());
  40. >    break;
  41.  
  42. >    default:
  43. >    atol((GetModule()->LoadString(ROOM_OVER)).c_str());
  44. >    }
  45.  
  46.  
  47. >I dont see any difference that should matter in any of these examples.
  48. >I obviously have a workaround, but I am also very currious.
  49. >Thanks for any answers to this mystery :o) !
  50. >    Brian
  51.  
  52. Yes this is basically a compiler bug, but I'm not sure Borland will
  53. admit it. There is nothing stopping you from doing this in the
  54. standard.
  55.  
  56. The problem is with the ? operator and classes rather than
  57. GetModule()->LoadString.  Many moons ago someone wrote an article
  58. about this bug. I don't remember who or where, but it was listed as
  59. 'Bug of the Month' (Dr Dobbs perhaps?)
  60.  
  61. Steve
  62.  
  63.